# find glib-2.0
# Once done this will define
# glib2_FOUND
# glib2_INCLUDE_DIRS - The glib-2.0 include directories
# glib2_LIBRARIES    - The libraries needed to use glib-2.0
# glib2_DEFINITIONS  - Compiler switches required for using glib-2.0

find_package(PkgConfig)
pkg_check_modules(PC QUIET glib-2.0)

#message(STATUS "LIBRARIES    : ${PC_LIBRARIES}")
#message(STATUS "LIBRARY DIRS : ${PC_LIBBRARY_DIRS}")
#message(STATUS "LDFLAGS      : ${PC_LDFLAGS}")
#message(STATUS "LDFLAGS OTHER: ${PC_LDFLAGS_OTHERS}")
#message(STATUS "INCLUDE DIRS : ${PC_INCLUDE_DIRS}")
#message(STATUS "CFLAGS       : ${PC_CFLAGS}")
#message(STATUS "CFLAGS OTHER : ${PC_CFLAGS_OTHER}")

set(glib2_DEFINITIONS ${PC_CFLAGS_OTHER})

find_path(glib2_INCLUDE_DIR  glib.h
        HINTS ${PC_INCLUDE_DIRS}
        PATH_SUFFIXES glib-2.0 )

find_path(glibconfig_INCLUDE_DIR glibconfig.h
        HINTS ${PC_INCLUDE_DIRS} )

find_library(glib2_LIBRARY NAMES glib-2.0
        HINTS ${PC_LIBRARY_DIRS} )

set(glib2_LIBRARIES ${glib2_LIBRARY} )
set(glib2_INCLUDE_DIRS ${glib2_INCLUDE_DIR} ${glibconfig_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set glib2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(glib2 DEFAULT_MSG
	glib2_LIBRARY glibconfig_INCLUDE_DIR glib2_INCLUDE_DIR)

mark_as_advanced(glib2_INCLUDE_DIR glibconfig_INCLUDE_DIR glib2_LIBRARY )
